/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interfaz;

import Interfaz.LoginInterfaz;
import Interfaz.Validacion;
import Interfaz.Validacion;
import Negocio.Ciudad;
import Negocio.CiudadCliente;
import Negocio.Cliente;
import Negocio.Compras;
import Negocio.Factura;
import Negocio.FacturaCliente;
import Negocio.Lista_cf;
import Negocio.Lista_ciudades;
import Negocio.Lista_clientes;
import Negocio.Lista_compras;
import Negocio.Lista_facturas;
import Negocio.Lista_login;
import Negocio.Lista_productos;
import Negocio.Login;
import Negocio.Producto;
import Negocio.Proveedor;
import Negocio.UsuarioLogin;
import Negocio.Usuarios;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Jorge
 */
public class AdministradorInterfaz extends javax.swing.JFrame {
    Cliente cliente = new Cliente();
    Ciudad ciudad = new Ciudad();
    Producto producto = new Producto();
    CiudadCliente cc = new CiudadCliente();
    Compras compra = new Compras();
    Login login = new Login();
    UsuarioLogin ul = new UsuarioLogin();
    Proveedor proveedor = new Proveedor();
    Factura factura = new Factura();
    Usuarios usuario = new Usuarios();
    FacturaCliente factCli = new FacturaCliente();
    Lista_cf listaFactCli = new Lista_cf();
    Lista_login listaLogin = new Lista_login();
    Lista_facturas listaFacturas = new Lista_facturas();
    Lista_compras listaCompras = new Lista_compras();   
    Lista_productos listaproductos = new Lista_productos();
    Lista_clientes listaClientes = new Lista_clientes();
    Lista_ciudades listaCiudades = new Lista_ciudades();
    Validacion validar = new Validacion();
    DefaultComboBoxModel comboCiudad = new DefaultComboBoxModel();
    /**
     * Creates new form AdministradorInterfaz
     */
    public AdministradorInterfaz() {
        initComponents();
        this.setTitle("ADMINISTRADOR");
    }
    
     public void limpiarTabla(JTable tbl){
        int aux = tbl.getRowCount();
        do{
            try{
                DefaultTableModel temp = (DefaultTableModel) tbl.getModel();
                temp.removeRow(temp.getRowCount()-1);
            }
            catch(ArrayIndexOutOfBoundsException e){
            }
            aux--;
        }while(aux > 0);
    }
    
    /*public void listarCompras(int id){
            listaCompras.listar(id);
            double precio;
            double suma=0;
            ArrayList compras = new ArrayList();
            compras = listaCompras.getCompras();
            DefaultTableModel temp = (DefaultTableModel) tblFactura.getModel();
            for (int i = tblFactura.getRowCount() - 1; i >= 0; i--) {
                temp.removeRow(i);
            }
            for (int i = 0; i < compras.size(); i++) {
                Compras otraCompra = new Compras();
                otraCompra = (Compras) compras.get(i);
                producto.setId(otraCompra.getP().getId());
                producto.buscar();
                precio=otraCompra.getP().getCantidad()*producto.getPrecio();
                suma=precio+suma;
                lblTotal.setText(suma+" $");
                Object nuevo[] = {otraCompra.getP().getId(), producto.getNombre(), otraCompra.getP().getCantidad(),  precio};
                temp.addRow(nuevo);            
            }
            tblFactura.setModel(temp);
    }*/
    
    private void limpiarcliente(){
        txtCedulaCli.setText("");
        txtNombreCli.setText("");
        txtApellidoCli.setText("");
        txtCalleCli.setText("");
        txtNumeroCli.setText("");
        txtTelefonoCli.setText("");
        txtCedulaCli.setEnabled(true);
        txtNombreCli.setEnabled(true);
        txtApellidoCli.setEnabled(true);
    }    
    
    private void actualizarcliente(){
        listaClientes.listar();
        ArrayList clientes = new ArrayList();
        clientes = listaClientes.getClientes();
        DefaultTableModel temp = (DefaultTableModel) tblClientesCompraAdm.getModel();
        for (int i = tblClientesCompraAdm.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < clientes.size(); i++) {
            Cliente otroCliente = new Cliente();
            otroCliente = (Cliente) clientes.get(i);
            cliente.setCedula(otroCliente.getCedula());
            cc.setC(cliente);
            cc.buscar();
            ciudad.setId(cc.getCiu().getId());
            ciudad.buscar();
            if(ciudad.getNombre()==null){
                Object nuevo[] = {otroCliente.getCedula(), otroCliente.getNombre(), otroCliente.getApellido(), otroCliente.getDir_calle(), otroCliente.getDir_numero(), otroCliente.getTelefono(), "Ciudad no agregada"};
                temp.addRow(nuevo);
            }
            else{
                Object nuevo[] = {otroCliente.getCedula(), otroCliente.getNombre(), otroCliente.getApellido(), otroCliente.getDir_calle(), otroCliente.getDir_numero(), otroCliente.getTelefono(), ciudad.getNombre()};
                temp.addRow(nuevo);
            }
            
        }
        tblClientesCompraAdm.setModel(temp);      
       }
    
    public void agregarCiudadesCombo() {
        comboCiudad.removeAllElements();
        listaCiudades.listar();
        ArrayList ciudades = listaCiudades.getCiudades();
        Iterator it = ciudades.iterator();
        while (it.hasNext()) {
            Ciudad c = (Ciudad) it.next();
            comboCiudad.addElement(c.getNombre());
        }
        cmbCiudad.setModel(comboCiudad);
    }
    
    private void actualizarciudad(){
        listaCiudades.listar();
        ArrayList ciudades = new ArrayList();
        ciudades = listaCiudades.getCiudades();
        DefaultTableModel temp = (DefaultTableModel) tblCiudades.getModel();
        for (int i = tblCiudades.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < ciudades.size(); i++) {
            Ciudad otraCiudad = new Ciudad();
            otraCiudad = (Ciudad) ciudades.get(i);
            Object nuevo[] = {otraCiudad.getId(), otraCiudad.getNombre()};
            temp.addRow(nuevo);
        }
        tblCiudades.setModel(temp);
    }
    
    private void actualizarfactura(){
        listaFacturas.listar();
        ArrayList facturas = new ArrayList();
        facturas = listaFacturas.getFacturas();
        DefaultTableModel temp = (DefaultTableModel) tblFacturasAdm.getModel();
        for (int i = tblFacturasAdm.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < facturas.size(); i++) {
            Factura otraFactura = new Factura();
            otraFactura = (Factura) facturas.get(i);
            Object nuevo[] = {otraFactura.getId(), otraFactura.getFecha()};
            temp.addRow(nuevo);
        }
        tblFacturasAdm.setModel(temp);
    }
    
    
    private void actualizarproducto(){
        listaproductos.listar();
        ArrayList prods = new ArrayList();
        prods = listaproductos.getProductos();
        DefaultTableModel temp = (DefaultTableModel) tblProductosAdm.getModel();
        for (int i = tblProductosAdm.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < prods.size(); i++) {
            Producto prod = new Producto();
            prod = (Producto) prods.get(i);
            proveedor.setId(prod.getProveedor().getId());
            proveedor.buscar();
            Object nuevo[] = {prod.getId(), prod.getNombre(), prod.getCantidad(), prod.getPrecio(), proveedor.getNombre()};
            temp.addRow(nuevo);
        }
        tblProductosAdm.setModel(temp);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuItem2 = new javax.swing.JMenuItem();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel22 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblFacturasAdm = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtCedulaFact = new javax.swing.JTextField();
        txtNombreFact = new javax.swing.JTextField();
        txtApellidoFact = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        txtidpro = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        txtnombrepro = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        txtcantidadpro = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        txtpreciopro = new javax.swing.JTextField();
        btnbuscarpro = new javax.swing.JButton();
        btnmodificarpro = new javax.swing.JButton();
        btnactualizarpro = new javax.swing.JButton();
        btnlimpiarpro = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblProductosAdm = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        txtIdCiudad = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        txtNombreCiudad = new javax.swing.JTextField();
        btnAgregarCiu = new javax.swing.JButton();
        btnBuscarCiu = new javax.swing.JButton();
        btnModificarCiu = new javax.swing.JButton();
        btnActualizarCiu = new javax.swing.JButton();
        btnLimpiarCiu = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        tblCiudades = new javax.swing.JTable();
        jPanel18 = new javax.swing.JPanel();
        btnBuscarCli = new javax.swing.JButton();
        btnModificarCli = new javax.swing.JButton();
        btnActualizarCli = new javax.swing.JButton();
        btnLimpiarCli = new javax.swing.JButton();
        btnEliminarCli = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        txtCedulaCli = new javax.swing.JTextField();
        txtNombreCli = new javax.swing.JTextField();
        txtApellidoCli = new javax.swing.JTextField();
        txtCalleCli = new javax.swing.JTextField();
        txtNumeroCli = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        txtTelefonoCli = new javax.swing.JTextField();
        jLabel25 = new javax.swing.JLabel();
        cmbCiudad = new javax.swing.JComboBox();
        jScrollPane6 = new javax.swing.JScrollPane();
        tblClientesCompraAdm = new javax.swing.JTable();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblLogin = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txtNombreLog = new javax.swing.JTextField();
        txtApellidoLog = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        lblCedUs = new javax.swing.JLabel();
        lblNombreUs = new javax.swing.JLabel();
        menuAdmin = new javax.swing.JMenuBar();
        jMenuAdmin = new javax.swing.JMenu();
        itemAdmin1 = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        itemAdmin2 = new javax.swing.JMenuItem();

        jMenuItem2.setText("jMenuItem2");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        tblFacturasAdm.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Num. Factura", "Fecha", "Total"
            }
        ));
        jScrollPane2.setViewportView(tblFacturasAdm);

        jButton1.setText("Buscar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton3.setText("Eliminar");

        jButton4.setText("Actualizar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jLabel3.setText("Nombre:");

        jLabel4.setText("Apellido:");

        jLabel5.setText("Cedula:");

        txtCedulaFact.setEnabled(false);

        txtNombreFact.setEnabled(false);

        txtApellidoFact.setEnabled(false);

        javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22);
        jPanel22.setLayout(jPanel22Layout);
        jPanel22Layout.setHorizontalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel22Layout.createSequentialGroup()
                .addGap(160, 160, 160)
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel3)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtNombreFact)
                    .addComponent(txtCedulaFact)
                    .addComponent(txtApellidoFact, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton4)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(53, 53, 53))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel22Layout.createSequentialGroup()
                .addContainerGap(82, Short.MAX_VALUE)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(81, 81, 81))
        );
        jPanel22Layout.setVerticalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel22Layout.createSequentialGroup()
                        .addGap(47, 47, 47)
                        .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(txtCedulaFact, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(txtNombreFact, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel22Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton4)
                    .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel4)
                        .addComponent(txtApellidoFact, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(34, 34, 34)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(103, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Facturas", jPanel22);

        jLabel15.setText("Id");
        jLabel15.setEnabled(false);

        txtidpro.setEnabled(false);

        jLabel16.setText("Nombre");

        txtnombrepro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtnombreproKeyPressed(evt);
            }
        });

        jLabel17.setText("Cantidad");

        txtcantidadpro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtcantidadproKeyPressed(evt);
            }
        });

        jLabel18.setText("Precio");

        txtpreciopro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtprecioproKeyPressed(evt);
            }
        });

        btnbuscarpro.setText("Buscar");
        btnbuscarpro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnbuscarproActionPerformed(evt);
            }
        });

        btnmodificarpro.setText("Modificar");
        btnmodificarpro.setEnabled(false);
        btnmodificarpro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnmodificarproActionPerformed(evt);
            }
        });

        btnactualizarpro.setText("Actualizar");
        btnactualizarpro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnactualizarproActionPerformed(evt);
            }
        });

        btnlimpiarpro.setText("Limpiar");
        btnlimpiarpro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnlimpiarproActionPerformed(evt);
            }
        });

        tblProductosAdm.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Id", "Nombre", "Cantidad", "Precio", "Proveedor"
            }
        ));
        jScrollPane3.setViewportView(tblProductosAdm);

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(106, 106, 106)
                        .addComponent(jLabel18)
                        .addGap(345, 345, 345)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnactualizarpro, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnmodificarpro, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnbuscarpro, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnlimpiarpro, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(64, 64, 64)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(150, Short.MAX_VALUE))
            .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel7Layout.createSequentialGroup()
                    .addGap(93, 93, 93)
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel15, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel17, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(txtnombrepro, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE)
                        .addComponent(txtidpro)
                        .addComponent(txtcantidadpro)
                        .addComponent(txtpreciopro))
                    .addContainerGap(343, Short.MAX_VALUE)))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(120, 120, 120)
                        .addComponent(jLabel18))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(btnbuscarpro)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnmodificarpro)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnactualizarpro)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnlimpiarpro)))
                .addGap(30, 30, 30)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(253, Short.MAX_VALUE))
            .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel7Layout.createSequentialGroup()
                    .addGap(38, 38, 38)
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel15)
                        .addComponent(txtidpro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel16)
                        .addComponent(txtnombrepro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel17)
                        .addComponent(txtcantidadpro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(txtpreciopro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(328, Short.MAX_VALUE)))
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 729, Short.MAX_VALUE)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 625, Short.MAX_VALUE)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        jTabbedPane1.addTab("Productos", jPanel4);

        jLabel12.setText("Id:");

        txtIdCiudad.setEnabled(false);

        jLabel13.setText("Nombre");

        txtNombreCiudad.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtNombreCiudadKeyPressed(evt);
            }
        });

        btnAgregarCiu.setText("Agregar");
        btnAgregarCiu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarCiuActionPerformed(evt);
            }
        });

        btnBuscarCiu.setText("Buscar");
        btnBuscarCiu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarCiuActionPerformed(evt);
            }
        });

        btnModificarCiu.setText("Modificar");
        btnModificarCiu.setEnabled(false);
        btnModificarCiu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarCiuActionPerformed(evt);
            }
        });

        btnActualizarCiu.setText("Actualizar");
        btnActualizarCiu.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnActualizarCiuMouseClicked(evt);
            }
        });
        btnActualizarCiu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnActualizarCiuActionPerformed(evt);
            }
        });

        btnLimpiarCiu.setText("Limpiar");
        btnLimpiarCiu.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnLimpiarCiuMouseClicked(evt);
            }
        });
        btnLimpiarCiu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarCiuActionPerformed(evt);
            }
        });

        tblCiudades.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Id", "Nombre"
            }
        ));
        jScrollPane4.setViewportView(tblCiudades);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(114, 114, 114)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel13)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtNombreCiudad, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
                    .addComponent(txtIdCiudad))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 131, Short.MAX_VALUE)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(btnActualizarCiu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnModificarCiu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnBuscarCiu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnAgregarCiu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnLimpiarCiu, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(88, 88, 88))
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(56, 56, 56)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(txtIdCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(9, 9, 9)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(txtNombreCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addComponent(btnAgregarCiu)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnBuscarCiu)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnModificarCiu)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnActualizarCiu)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnLimpiarCiu)))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(91, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 615, Short.MAX_VALUE)
            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 486, Short.MAX_VALUE)
            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        jTabbedPane1.addTab("Ciudad", jPanel5);

        btnBuscarCli.setText("Buscar");
        btnBuscarCli.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarCliActionPerformed(evt);
            }
        });

        btnModificarCli.setText("Modificar");
        btnModificarCli.setEnabled(false);
        btnModificarCli.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarCliActionPerformed(evt);
            }
        });

        btnActualizarCli.setText("Actualizar");
        btnActualizarCli.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnActualizarCliActionPerformed(evt);
            }
        });

        btnLimpiarCli.setText("Limpiar");
        btnLimpiarCli.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarCliActionPerformed(evt);
            }
        });

        btnEliminarCli.setText("Eliminar");
        btnEliminarCli.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarCliActionPerformed(evt);
            }
        });

        jLabel10.setText("Num. Compras");

        jLabel11.setText("jLabel11");

        jLabel19.setText("Cedula:");

        jLabel20.setText("Nombre:");

        jLabel21.setText("Apellido:");

        jLabel22.setText("Direccion Calle:");

        jLabel23.setText("Dierccion numero:");

        jLabel24.setText("Telefono:");

        jLabel25.setText("Ciudad:");

        cmbCiudad.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        tblClientesCompraAdm.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Id", "Nombre", "Cantidad"
            }
        ));
        jScrollPane6.setViewportView(tblClientesCompraAdm);

        javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
        jPanel18.setLayout(jPanel18Layout);
        jPanel18Layout.setHorizontalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addGap(73, 73, 73)
                .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel18Layout.createSequentialGroup()
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(90, Short.MAX_VALUE))
                    .addGroup(jPanel18Layout.createSequentialGroup()
                        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel20)
                            .addComponent(jLabel19)
                            .addComponent(jLabel21)
                            .addComponent(jLabel22)
                            .addComponent(jLabel23)
                            .addComponent(jLabel24)
                            .addComponent(jLabel25))
                        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel18Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtApellidoCli)
                                    .addComponent(txtCedulaCli)
                                    .addComponent(txtNombreCli)))
                            .addGroup(jPanel18Layout.createSequentialGroup()
                                .addGap(4, 4, 4)
                                .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtCalleCli)
                                    .addComponent(txtNumeroCli)
                                    .addComponent(txtTelefonoCli)
                                    .addComponent(cmbCiudad, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel18Layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel11)
                                .addGap(41, 41, 41)
                                .addComponent(btnBuscarCli, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(btnModificarCli, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnEliminarCli, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnActualizarCli)
                            .addComponent(btnLimpiarCli, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(23, 23, 23))))
        );
        jPanel18Layout.setVerticalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel18Layout.createSequentialGroup()
                        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnBuscarCli)
                            .addComponent(jLabel10)
                            .addComponent(jLabel11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnModificarCli)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnEliminarCli)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnActualizarCli)
                        .addGap(5, 5, 5)
                        .addComponent(btnLimpiarCli)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel25)
                            .addComponent(cmbCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel18Layout.createSequentialGroup()
                        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel19)
                            .addComponent(txtCedulaCli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNombreCli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel20))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtApellidoCli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel21))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel22)
                            .addComponent(txtCalleCli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNumeroCli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel23))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel24)
                            .addComponent(txtTelefonoCli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(60, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Clientes", jPanel18);

        tblLogin.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Usuario", "Fecha", "Hora"
            }
        ));
        jScrollPane1.setViewportView(tblLogin);

        jLabel1.setText("Nombre:");

        jLabel2.setText("Apellido:");

        jButton2.setText("Buscar");

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGap(172, 172, 172)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtApellidoLog))
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtNombreLog, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(80, 80, 80)
                        .addComponent(jButton2))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGap(74, 74, 74)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(89, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                .addGap(55, 55, 55)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtNombreLog, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtApellidoLog, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(43, 43, 43)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(113, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Log In", jPanel8);

        jLabel7.setText("Usuario:");

        lblCedUs.setText("0103849873");

        lblNombreUs.setText("jLabel4");

        jMenuAdmin.setText("File");

        itemAdmin1.setText("Cerrar Sesion");
        jMenuAdmin.add(itemAdmin1);
        jMenuAdmin.add(jSeparator1);

        itemAdmin2.setText("Salir");
        itemAdmin2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemAdmin2ActionPerformed(evt);
            }
        });
        jMenuAdmin.add(itemAdmin2);

        menuAdmin.add(jMenuAdmin);

        setJMenuBar(menuAdmin);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblCedUs)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblNombreUs, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 620, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(lblCedUs)
                    .addComponent(lblNombreUs))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 430, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void itemAdmin2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemAdmin2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_itemAdmin2ActionPerformed

    private void txtNombreCiudadKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombreCiudadKeyPressed
        // TODO add your handling code here:
        validar.ValidarPalabras(txtNombreCiudad);
    }//GEN-LAST:event_txtNombreCiudadKeyPressed

    private void btnAgregarCiuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarCiuActionPerformed
        // TODO add your handling code here:
        if (txtNombreCiudad.getText().equals("")){
            JOptionPane.showMessageDialog(null, "Faltan Datos");

        }
        else{
            ciudad.setNombre(txtNombreCiudad.getText());
            ciudad.grabar();
            btnLimpiarCiu.doClick();
            btnActualizarCiu.doClick();
        }

    }//GEN-LAST:event_btnAgregarCiuActionPerformed

    private void btnBuscarCiuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarCiuActionPerformed
        // TODO add your handling code here:
        try{
            int id = Integer.parseInt(JOptionPane.showInputDialog("Ingrese la Id"));
            ciudad.setId(id);
            ciudad.buscar();
            if (ciudad.getNombre() == null) {
                txtIdCiudad.setText("");
                txtNombreCiudad.setText("");
            }
            else{
                btnModificarCiu.setEnabled(true);
                txtIdCiudad.setText(ciudad.getId()+"");
                txtNombreCiudad.setText(ciudad.getNombre());
            }
        } catch(Exception e){
            JOptionPane.showMessageDialog(null, "Operacion Cancelada");
        }
    }//GEN-LAST:event_btnBuscarCiuActionPerformed

    private void btnModificarCiuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarCiuActionPerformed
        // TODO add your handling code here:
        ciudad.setNombre(txtNombreCiudad.getText());
        ciudad.modificar();
        btnModificarCiu.setEnabled(false);
    }//GEN-LAST:event_btnModificarCiuActionPerformed

    private void btnActualizarCiuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnActualizarCiuMouseClicked

    }//GEN-LAST:event_btnActualizarCiuMouseClicked

    private void btnActualizarCiuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnActualizarCiuActionPerformed
        actualizarciudad();
    }//GEN-LAST:event_btnActualizarCiuActionPerformed

    private void btnLimpiarCiuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnLimpiarCiuMouseClicked

    }//GEN-LAST:event_btnLimpiarCiuMouseClicked

    private void btnLimpiarCiuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarCiuActionPerformed
        // TODO add your handling code here:
        txtIdCiudad.setText("");
        txtNombreCiudad.setText("");
    }//GEN-LAST:event_btnLimpiarCiuActionPerformed

    private void btnEliminarCliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarCliActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnEliminarCliActionPerformed

    private void btnLimpiarCliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarCliActionPerformed
        // TODO add your handling code here:
        limpiarcliente();
    }//GEN-LAST:event_btnLimpiarCliActionPerformed

    private void btnActualizarCliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnActualizarCliActionPerformed
        actualizarcliente();
    }//GEN-LAST:event_btnActualizarCliActionPerformed

    private void btnModificarCliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarCliActionPerformed
        // TODO add your handling code here:
        cliente.setDir_calle(txtCalleCli.getText());
        cliente.setDir_numero(txtNumeroCli.getText());
        cliente.setTelefono(txtTelefonoCli.getText());
        String nombre = comboCiudad.getSelectedItem().toString();
        ciudad.setNombre(nombre);
        ciudad.buscarNombre();
        cliente.setCedula(txtCedulaCli.getText());
        cc.setC(cliente);
        cc.setCiu(ciudad);
        /*cc.buscar();
        System.out.println(cc.getCiu().getNombre());
        System.out.println(cc.getC().getCedula());
        if(cc.getCiu().getNombre()==null){
            System.out.println("1");
            cc.setCiu(ciudad);
            cc.grabar();
            System.out.println(cc.getC().getCedula()+" "+cc.getCiu().getNombre());
        }else if(cc.getC().getCedula()==null){
            System.out.println("2");
            cliente.setCedula(txtCedula.getText());
            cc.setC(cliente);
            cc.grabar();
        }
        else{
            System.out.println("3");
            cc.modificar();
            cliente.modificar();
        }*/
        cc.modificar();
        cliente.modificar();
        btnModificarCli.setEnabled(false);
        txtCedulaCli.setEnabled(true);
        txtNombreCli.setEnabled(true);
        txtApellidoCli.setEnabled(true);
        limpiarcliente();
    }//GEN-LAST:event_btnModificarCliActionPerformed

    private void btnBuscarCliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarCliActionPerformed
        try{
            String cedu =  JOptionPane.showInputDialog("Ingrese una cedula");
            if(cedu.equals("")==false){
                cliente.setCedula(cedu);
                cliente.buscar();
                if (cliente.getNombre() == null) {
                    txtNombreCli.setText("");
                    txtApellidoCli.setText("");
                    txtCalleCli.setText("");
                    txtNumeroCli.setText("");
                    txtTelefonoCli.setText("");
                    btnModificarCli.setEnabled(false);
                } else {
                    btnModificarCli.setEnabled(true);
                    txtCedulaCli.setEnabled(false);
                    txtCedulaCli.setText(cliente.getCedula());
                    txtNombreCli.setText(cliente.getNombre());
                    txtApellidoCli.setText(cliente.getApellido());
                    txtNombreCli.setEnabled(false);
                    txtApellidoCli.setEnabled(false);
                    txtCalleCli.setText(cliente.getDir_calle());
                    txtNumeroCli.setText(cliente.getDir_numero());
                    txtTelefonoCli.setText(cliente.getTelefono()+"");
                }
            }
        }
        catch(Exception e){
            JOptionPane.showMessageDialog(null, "Operacion Cancelada");
        }
    }//GEN-LAST:event_btnBuscarCliActionPerformed

    private void btnlimpiarproActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnlimpiarproActionPerformed
        txtidpro.setText("");
        txtnombrepro.setText("");
        txtcantidadpro.setText("");
        txtpreciopro.setText("");
        limpiarTabla(tblProductosAdm);
    }//GEN-LAST:event_btnlimpiarproActionPerformed

    private void btnactualizarproActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnactualizarproActionPerformed
        // TODO add your handling code here:
        actualizarproducto();
    }//GEN-LAST:event_btnactualizarproActionPerformed

    private void btnmodificarproActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnmodificarproActionPerformed
        producto.setNombre(txtnombrepro.getText());
        producto.setCantidad(Integer.parseInt(txtcantidadpro.getText()));
        producto.setPrecio(Double.parseDouble(txtpreciopro.getText()));
        producto.modificar();
        btnmodificarpro.setEnabled(false);
    }//GEN-LAST:event_btnmodificarproActionPerformed

    private void btnbuscarproActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnbuscarproActionPerformed
        try{
            int id = Integer.parseInt(JOptionPane.showInputDialog("Ingrese la Id"));
            producto.setId(id);
            producto.buscar();
            if (producto.getNombre() == null) {
                txtidpro.setText("");
                txtnombrepro.setText("");
                txtcantidadpro.setText("");
                txtpreciopro.setText("");
            }
            else{
                btnmodificarpro.setEnabled(true);
                txtidpro.setText(String.valueOf(id));
                txtidpro.setText(String.valueOf(producto.getId()));
                txtnombrepro.setEnabled(false);
                txtnombrepro.setText(producto.getNombre());
                txtcantidadpro.setText(String.valueOf(producto.getCantidad()));
                txtpreciopro.setText(String.valueOf(producto.getPrecio()));
            }}
            catch(Exception e){
                JOptionPane.showMessageDialog(null, "Operacion Cancelada");
            }
    }//GEN-LAST:event_btnbuscarproActionPerformed

    private void txtprecioproKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtprecioproKeyPressed
        // TODO add your handling code here:
        validar.ValidarDecimales(txtpreciopro);
    }//GEN-LAST:event_txtprecioproKeyPressed

    private void txtcantidadproKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtcantidadproKeyPressed
        // TODO add your handling code here:
        validar.ValidarNumeros(txtcantidadpro);
    }//GEN-LAST:event_txtcantidadproKeyPressed

    private void txtnombreproKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtnombreproKeyPressed
        // TODO add your handling code here:
        validar.ValidarPalabras(txtnombrepro);
    }//GEN-LAST:event_txtnombreproKeyPressed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        int num = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el numero de factura"));
        factura.setId(num);
        factura.buscar();
        factCli.setF(factura);
        factCli.buscar();
        cliente.setCedula(factCli.getC().getCedula());
        cliente.buscar();
        txtCedulaFact.setText(cliente.getCedula());
        txtNombreFact.setText(cliente.getNombre());
        txtApellidoFact.setText(cliente.getApellido());
        
    }//GEN-LAST:event_jButton1ActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:
        login.setId(listaLogin.getId());
        ul.setLogin(login);
        ul.buscarId();        
        usuario.setCedula(ul.getUsuario().getCedula());
        usuario.buscar();
        lblCedUs.setText(usuario.getCedula());
        lblNombreUs.setText(usuario.getNombre()+" "+usuario.getApellido());
    }//GEN-LAST:event_formWindowOpened

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        actualizarfactura();
    }//GEN-LAST:event_jButton4ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AdministradorInterfaz.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AdministradorInterfaz.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AdministradorInterfaz.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AdministradorInterfaz.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new AdministradorInterfaz().setVisible(false);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnActualizarCiu;
    private javax.swing.JButton btnActualizarCli;
    private javax.swing.JButton btnAgregarCiu;
    private javax.swing.JButton btnBuscarCiu;
    private javax.swing.JButton btnBuscarCli;
    private javax.swing.JButton btnEliminarCli;
    private javax.swing.JButton btnLimpiarCiu;
    private javax.swing.JButton btnLimpiarCli;
    private javax.swing.JButton btnModificarCiu;
    private javax.swing.JButton btnModificarCli;
    private javax.swing.JButton btnactualizarpro;
    private javax.swing.JButton btnbuscarpro;
    private javax.swing.JButton btnlimpiarpro;
    private javax.swing.JButton btnmodificarpro;
    private javax.swing.JComboBox cmbCiudad;
    private javax.swing.JMenuItem itemAdmin1;
    private javax.swing.JMenuItem itemAdmin2;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JMenu jMenuAdmin;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel18;
    private javax.swing.JPanel jPanel22;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lblCedUs;
    private javax.swing.JLabel lblNombreUs;
    private javax.swing.JMenuBar menuAdmin;
    private javax.swing.JTable tblCiudades;
    private javax.swing.JTable tblClientesCompraAdm;
    private javax.swing.JTable tblFacturasAdm;
    private javax.swing.JTable tblLogin;
    private javax.swing.JTable tblProductosAdm;
    private javax.swing.JTextField txtApellidoCli;
    private javax.swing.JTextField txtApellidoFact;
    private javax.swing.JTextField txtApellidoLog;
    private javax.swing.JTextField txtCalleCli;
    private javax.swing.JTextField txtCedulaCli;
    private javax.swing.JTextField txtCedulaFact;
    private javax.swing.JTextField txtIdCiudad;
    private javax.swing.JTextField txtNombreCiudad;
    private javax.swing.JTextField txtNombreCli;
    private javax.swing.JTextField txtNombreFact;
    private javax.swing.JTextField txtNombreLog;
    private javax.swing.JTextField txtNumeroCli;
    private javax.swing.JTextField txtTelefonoCli;
    private javax.swing.JTextField txtcantidadpro;
    private javax.swing.JTextField txtidpro;
    private javax.swing.JTextField txtnombrepro;
    private javax.swing.JTextField txtpreciopro;
    // End of variables declaration//GEN-END:variables
}
